from django.db import models

# Create your models here.

class Classroom(models.Model):
    c_number = models.IntegerField(verbose_name='序号')
    c_name = models.CharField(max_length=8, verbose_name='名字')
    c_student = models.IntegerField(verbose_name='人数')
    c_theory = models.BooleanField(verbose_name='是否理论教室', default=True)
    c_img = models.FileField(verbose_name='图片', upload_to='zichan_oa/')

    def theory(self):
        if self.c_theory == True:
            return "是"
        else:
            return "否"

    theory.short_description = '是否理论教室'

    def __str__(self):
        return '%s' % self.c_name

    class Meta():
        verbose_name_plural = '教室管理'

class Equipment(models.Model):
    e_number = models.IntegerField(verbose_name='序号')
    e_name = models.CharField(max_length=8, verbose_name='名称')
    e_classroom = models.ForeignKey('Classroom', on_delete=models.CASCADE, verbose_name='教室')
    e_img = models.FileField(verbose_name='图片', upload_to='zichan_oa/')
    e_status = models.BooleanField(verbose_name='是否正常', default=True)

    def status(self):
        if self.e_status == True:
            return "是"
        else:
            return "否"

    status.short_description = '是否正常'

    def __str__(self):
        return '%s' % self.e_name

    class Meta():
        verbose_name_plural = '设备管理'

class Hygienism(models.Model):
    h_number = models.IntegerField(verbose_name='序号')
    h_name = models.CharField(max_length=16, verbose_name='名称')
    h_status = models.CharField(max_length=8, verbose_name='卫生情况')
    h_classroom = models.ForeignKey('Classroom', on_delete=models.CASCADE, verbose_name='教室')
    h_admin = models.CharField(max_length=16, verbose_name='负责人')
    h_time = models.DateTimeField(verbose_name='时间')
    h_img = models.FileField(verbose_name='图片', upload_to='zichan_oa/')

    def __str__(self):
        return '%s' % self.h_name

    class Meta():
        verbose_name_plural = '卫生管理'

